﻿@using Lavka.Core
@using Lavka.Models
@model IEnumerable<Lavka.Models.Products>
         
    @foreach (Products item in Model)
    {
            <div class="galery-item">
            <table width="100%" style="height: 180px;">
            <tr>
            <td>
                @if (!string.IsNullOrEmpty(item.Photo))
                {
                    var thumbPath = Path.Combine("~/upload/products/thumbnails/", Path.GetFileName(item.Photo));
                    <a href="@Url.Content(item.Photo)" title="@item.Name" class="thickbox">
                        <img src="@Url.Content(thumbPath)" alt="@item.Name" class="small-image" />
                    </a>                   
                }
            </td>
            <td>
                @if (!string.IsNullOrEmpty(item.Name))
                {
                    @Html.ActionLink(item.Name, "Details", new { id = item.ProductId })
                }   

                <div class="details-header">Артикул</div>
                <div>@item.Reference</div>

                <div class="details-header">Производитель</div>
                <div>@item.Brands.Name</div>                          
            </td>
            </tr>
            <tr>
            <td style="vertical-align: middle;">
                @{
                var actionPrice = ActionsHelper.GetActionPrice(item, new LavkaDbEntities());
                if (actionPrice != null)
                {
                        <div class="menu-action-price">@String.Format("{0:0.00}", item.Price) грн.</div>
                        <div class="galery-price">@String.Format("{0:0.00}", actionPrice) грн.</div>
                }
                else
                {
                        <div class="galery-price">@String.Format("{0:0.00}", item.Price) грн.</div>
                }
                }            
            </td>
            <td style="vertical-align: middle;">
                @if (!CartHelper.IsProductInCart(item))
                {
                         <div style="float: right;">
                            <a href="@Url.Content("~/Products/AddToCart/" + item.ProductId)">
                                <img src="@Url.Content("~/Content/images/cart-green.png")" alt="@item.Name" style="vertical-align: middle;" />
                            </a>
                         </div>
                }
                else
                {
                    <div style="color: lightsteelblue; font-weight: bold; float: right;">Добавлен</div>
                }            
            </td>
            </tr>
            </table>     
            </div>
    }

<script type="text/javascript">
    $(document).ready(initPopupImage());
    $(".galery-item").corner();
</script>